# 从redis中导入StrictRedis
from redis import StrictRedis


class Config(object):
    # 为数据库配置
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/information27"
    # 关闭跟踪
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # 请求结束后会自动commit,做提交
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True

    # 为redis配置
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379

    # 设置session的加密钥匙
    SECRET_KEY = "ssssss"
    # flask_session的配置信息
    SESSION_TYPE = "redis"
    # 打开设置签名---更安全
    SESSION_USE_SIGNER = True
    #使用 redis 的实例
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    # session 的有效期，单位是秒
    PERMANENT_SESSION_LIFETIME = 86400 * 2



class DevelopmentConfig(Config):
    """调试模式"""
    DEBUG = True


class TestingConfig(Config):
    """测试模式"""
    DEBUG = True
    TESTING = True


class ProductionConfig(Config):
    """生产环境下的配置"""
    DEBUG = False



# 定义配置字典
config = {
    "development": DevelopmentConfig,
    "production": ProductionConfig,
    "testing": TestingConfig
}